﻿#include "cameraworker.h"
#include <QThread>
CameraWorker::CameraWorker(QObject *parent) : QObject(parent)
{
    m_bIsStreaming = false;
    m_control = new SBaslerCameraControl(this);
}

CameraWorker::~CameraWorker()
{
}
void CameraWorker::Initialize()
{
    m_control->initSome();
    connect(m_control, &SBaslerCameraControl::sigCurrentImage, this, &CameraWorker::OnFrameReady);

    m_control->OpenCamera(m_cData.qStrCameraID);
    /*m_control->setFeatureTriggerSourceType("Line1");
    m_control->getFeatureTriggerSourceType();*/
}

void CameraWorker::start()
{
    m_control->StartAcquire();
}

void CameraWorker::stop()
{
    m_control->StopAcquire();
}

void CameraWorker::OnFrameReady(int count){
    //QImage img = m_control->GetFrame();
    //HalconCpp::HObject hImg;
    //int width = img.width(), height = img.height();
    //HalconCpp::GenImage1(&hImg, "byte", width, height, (Hlong)(img.bits()));
    //m_cData.Hobj = hImg;
    //emit sigAlgStart(m_cData);
	m_cData.Hobj = m_control->GetFrame();
	emit sigAlgStart(m_cData);
}

void CameraWorker::SlotsFrameNums()
{
    m_control->m_nImgeBuff--;
}
